package x.y.z;

import java.util.Stack;

public class Interview_3_2_StackMin {

}

class MinStack {

    Stack<Integer> stack;
    Stack<Integer> min;

    /**
     * initialize your data structure here.
     */
    public MinStack() {
        stack = new Stack<>();
        min = new Stack<>();
    }

    public void push(int x) {
        stack.push(x);
        if (min.isEmpty()) {
            min.push(x);
        } else {
            if (x > min.peek()) {
                min.push(min.peek());
            } else {
                min.push(x);
            }
        }
    }

    public void pop() {
        stack.pop();
        min.pop();
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return min.peek();
    }
}
